package com.xzh.Action;

import com.opensymphony.xwork2.ActionSupport;
import com.xzh.Dao.UserDaoImpl;
import com.xzh.Entity.User;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;


import java.util.List;

public class LoginServiceAction extends ActionSupport {
    private String  username;
    private String  password;
    private UserDaoImpl userDao;

    public void setUserDao(UserDaoImpl userDao) {
        this.userDao = userDao;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }
    public String execute() throws Exception{
       List<User>userList=userDao.findByNmae(username);
        for (User user:userList){
            if (user.getPassword().equals(password)){
                return SUCCESS;
            }
            else {
                return ERROR;
            }
        }
        return ERROR;
    }
}
